package com.lunatic.enumdemo;

import lombok.Data;

@Data
public class Pizza001 {

    private PizzaStatus status;

    public boolean isDeliverable() {
        return this.status.isDelivered();
    }

    public boolean isReady() {
        return this.status.isReady();
    }

    public boolean isOrdered() {
        return this.status.isOrdered();
    }

    public enum PizzaStatus {

        // 枚举属性加构造方法
        ORDERED(5) {
            @Override
            public boolean isOrdered() {
                return true;
            }
        },
        READY(2) {
            @Override
            public boolean isReady() {
                return true;
            }
        },
        DELIVERED(0) {
            @Override
            public boolean isDelivered() {
                return true;
            }
        };

        // 枚举属性
        private int timeToDelivery;

        // 枚举构造方法
        PizzaStatus(int timeToDelivery) {
            this.timeToDelivery = timeToDelivery;
            System.out.println(timeToDelivery);
        }

        // 枚举方法
        public boolean isOrdered() {
            return false;
        }

        public boolean isReady() {
            return false;
        }

        public boolean isDelivered() {
            return false;
        }


    }
}
